# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=python-devtools
pkgver=0.12.2
pkgrel=1
pkgdesc="Dev tools for Python"
arch=(any)
url="https://github.com/samuelcolvin/python-devtools"
license=(MIT)
depends=(
  python
  python-asttokens
  python-executing
)
makedepends=(
  python-build
  python-hatchling
  python-installer
)
checkdepends=(
  python-asyncpg
  python-multidict
  python-numpy
  python-pygments
  python-pytest
  python-pytest-mock
  python-pytest-pretty
  python-sqlalchemy
)
optdepends=(
  'python-pygments: for colored output'
  'python-pytest: for pytest plugin'
  'python-sqlalchemy: for pretty-display of sqlalchemy objects'
)
source=($pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz)
sha512sums=('7d7c2f1b6aeafae60c48f171179b29a304bf9231f7325c8bd19cd2249ad343d4c550af92a4e71b3d5a6660228449dd4c3f42b42b4ed2edd862be444fa2235ce5')
b2sums=('ec059bba343da3a4727170e809db2f5d78a1c336371d3affcd862d22441e979de40434c02b57e69934d2d600d52d282f793ad52f3ce93594b637fe31f9be7c98')

build() {
  cd $pkgname-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local pytest_options=(
    -vv
    # https://github.com/samuelcolvin/python-devtools/issues/132
    --deselect tests/test_insert_assert.py::test_insert_assert
    --deselect tests/test_insert_assert.py::test_deep
    --deselect tests/test_insert_assert.py::test_enum
  )

  cd $pkgname-$pkgver
  pytest "${pytest_options[@]}"
}

package() {
  cd $pkgname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
